<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="js/lib/jquery-3.3.1.min.js"></script>
<script type="text/javascript">
	$(function(){
		$("#addbtn").on("click",function(){
				$.ajax({
					url:"<%=basePath%>emp/action/add",
					method: "post",
					data:{"empNo":"111s", "salary": "20.2"},
					dataType: "json",
					success: function(data){
						$("#msg").text(data.flag);
					},
					error:function(){
						alert("对不起，增加用户失败!");
					}
				});
				
			});
		
		$("#delbtn").on("click",function(){
			$.ajax({
				url:"<%=basePath%>emp/action/delete?empNo=111",
				method: "delete",
// 				data: "empNo=111",
				dataType: "json",
				success: function(data){
					$("#msg").text(data.flag);
				},
				error:function(){
					alert("对不起，删除用户失败!");
				}
			});
		});
		
		$("#putbtn").on("click",function(){
			$.ajax({
				url:"<%=basePath%>emp/action/update",
				method: "put",
				data:{"empNo":"111", "salary": "20.2"},
				dataType: "json",
				success: function(data){
					$("#msg").text(data.flag);
				},
				error:function(){
					alert("对不起，修改用户失败!");
				}
			});
			
		});
		
		$("#getbtn").on("click",function(){
			$.ajax({
				url:"<%=basePath%>emp/action/get",
				method: "get",
				dataType: "json",
				success: function(data){
					$("#msg").text(data.data.empNo+":"+data.data.salary+":"+data.data.birthday);
				},
				error:function(){
					alert("对不起，获取用户失败!");
				}
			});
			
		});
		
	});

</script>
<title>Insert title here</title>
</head>
<body>
	<h2>这个是添加用户的测试页面</h2>

	<button id="addbtn" name="addbtn">添加用户</button><br/>
	<button id="delbtn" name="delbtn">删除用户</button><br/>
	<button id="putbtn" name="putbtn">修改用户</button><br/>
	<button id="getbtn" name="getbtn">获取用户</button><br/>
	
	<span id="msg"></span>

</body>
</html>
